package br.com.portalnet.view.managed;


import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;

import org.hibernate.Session;

import br.com.portalnet.persistence.INivelDAO;
import br.com.portalnet.persistence.NivelDAO;

import br.com.portalnet.model.Nivel;
import javax.faces.model.ListDataModel;
import javax.faces.model.DataModel;


@ManagedBean 
@SessionScoped
public class NivelMB 
{
	
	
	private Nivel nivel;
	private DataModel listaNiveis;
	
	public NivelMB()
	{		
		nivel = new Nivel();		
	}
	
	
	
	public DataModel getListarNiveis() 
	{
		List<Nivel> lista = new NivelDAO().list();
		listaNiveis = new ListDataModel(lista);
		return listaNiveis;
	}

	public Nivel getNivel() {
		return nivel;
	}

	public void setNivel(Nivel nivel) {
		this.nivel = nivel;
	}
	
	
	
	public String adicionarLivro()
	{		
		INivelDAO dao = new NivelDAO();
		dao.save(nivel);
		return "index";
	}




	
	
	
	
	
}
